package ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.devicecontroller.command;

import net.wimpi.modbus.msg.ModbusRequest;
import net.wimpi.modbus.msg.ModbusResponse;
import net.wimpi.modbus.msg.WriteSingleRegisterRequest;
import net.wimpi.modbus.procimg.SimpleRegister;

public class RegisterCommand extends AbstractCommand implements WordCommand{

	public int value;
	
	public RegisterCommand(){
		super();
	}
	@Override
	public boolean needRetrieve() {
		return false;
	}

	@Override
	public ModbusRequest getRetriveRequest() throws CommandException {
		throw new CommandException("RegisterCommand has not retrieve request");
	}

	@Override
	public void setRetrieveResponse(ModbusResponse res) throws CommandException {
		throw new CommandException("RegisterCommand can not process RetrieveResponse");
	}

	@Override
	public ModbusRequest getCommandRequest() {
		return new WriteSingleRegisterRequest(getAddress(), new SimpleRegister(value));
	}

	/**
	 * @return the value
	 */
	public int getValue() {
		return value;
	}

	/**
	 * @param value the value to set
	 */
	public void setValue(int value) {
		this.value = value;
	}

}
